from flask import Flask,render_template,request
#render_template渲染模板

app = Flask(__name__)


#返回用户渲染后的网页文件，向页面传递一个变量
@app.route('/')
def hello_world():
    num = 123
    name=["jack","bob","tom"] #列表类型
    people = {"name":"jack", "age":12} # 字典类型
    return render_template("test/flaskTest/index.html", var=num, list=name, people=people)

@app.route('/form')
def myform():
    return render_template("test/flaskTest/testForm.html")

@app.route('/result',methods=['POST','GET'])
def result():
    if request.method=='POST':
        result = request.form
        return render_template("test/flaskTest/result.html", result=result)



#链接带参数
@app.route('/h/<name>') #http://127.0.0.1:5000/h/helllll
def str(name):
    return 'Hello,%s'%name
@app.route('/h/<int:id>') #http://127.0.0.1:5000/h/helllll
def num(id):
    return '%d'%id

if __name__ == '__main__':
    app.run()
